//
//  ColorManager.m
//  04_homework_颜色处理
//
//  Created by dllo on 16/7/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ColorManager.h"
#import "Color.h"

@implementation ColorManager
- (instancetype)initWithDictionary:(NSMutableDictionary *)dictionary {
    self = [super init];
    if (self) {
        _colorSorts = dictionary;
    }
    return self;
}

- (void)sortColor:(NSMutableDictionary *)colorDic {
    for (NSString *key in colorDic) {
        Color *color = [[Color alloc] init];
        [color setName:key];
        [color setColorValue:colorDic[key]];
//        NSLog(@"%@", color);
        NSString *colorInitial = [key substringToIndex:1];
        NSMutableArray *colorArr = self.colorSorts[colorInitial];
        if (colorArr == nil) {
            colorArr = [NSMutableArray array];
            [self.colorSorts setObject:colorArr forKey:colorInitial];
        }
        [colorArr addObject:color];
    }
}
@end
